package com.yawn.demomybatismapper.controller;

import com.yawn.demomybatismapper.dao.BookDao;
import com.yawn.demomybatismapper.entity.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class BookController {

    @Autowired
    private BookDao bookDao;

    @GetMapping("list")
    public List<Book> list() {
        Book book = bookDao.selectByPrimaryKey(2);
        System.out.println(book);
        List<Book> bookList = bookDao.list();
        System.out.println(bookList);
        List<Book> bookList1 = bookDao.select(new Book(null, "Java"));
        System.out.println(bookList1);
        return bookDao.selectAll();
    }
}
